#include "stdafx.h"
#include "../../GameCore/CGame.h"
//extern "C" void InitADManager();
//extern "C" void InitADBanner();
//extern "C" void LoadOnlineData(char* name);
void CGame::UpdateLogo()
{
	if (_GameSubState == k_INIT)
	{
		//LoadResourceManifes("rm");
       // LoadOnlineData("b");
        
		//load res
		//LoadSprite(GFX_BALL_BLUE);
		//printf("\nk_init");
		//InitMathTable();
		
		//LoadSprite(GFX_LOADING);
		_loading_step = -6;
		_loading_opacity = 0;
		_flag_opacity = 0;
		_menu_opacity = 100;
		SetSubState(k_LOOP);
				
		//load text
		
		
		//SetSubState(k_FIRST_TIME);
	}
	else if (_GameSubState == k_LOOP)
	{
		//SetGameState(k_GS_PLAYGAME, true);
		if(_loading_step < 0)
		{
			//printf("\nK_Loop");
			_loading_step++;
			Sleep(500);
		}
		_loading_opacity += 3;//3
		if(_loading_opacity >= 60)
		{
			_flag_opacity += 1;
			//printf("\nflag_opacity===%d,_loading_step===%d",_flag_opacity,_loading_step);
		}
		if(_flag_opacity >= 100)
		{
			_loading_opacity = 100;
			switch(_loading_step)
			{
			case 0:
				//GameDataLoad();
			
				break;
			case 2:
				LoadSprite();
				break;
			case 3:
				
				break;
			case 5:
				
				break;
			case 6:	
				
				break;
			case 7:
				
				break;
			case 8:
				
				break;
			case 9:
				
				break;
			case 10:
				
				break;
			case 11:
				
				break;
			case 12:
				
				break;
			case 13:
				//GameDataLoad();
				break;
			}
		
			if(_loading_step >= 45)
			{
				_menu_opacity -= 10;
				if(_menu_opacity <= 30)
				{					
					//Load lvl from save																					

					/*for (int i = 0; i < GUN_TOTAL_SLOT; i++)
					{						
						if (i == 0)
						{
							_choose_weapon_temp_id[i] = GUN_ID_TOMATO;
						}
						else
						{
							_choose_weapon_temp_id[i] = -1;
						}
						
					}*/

					SetGameState(k_GS_PLAYGAME,true);//k_GS_PLAYGAME	
					printf("SetGameState=k_GS_PLAYGAME\n");
				}
			}
			_loading_step++;
		}
	}
	else if (_GameSubState == k_DESTROY)
	{
		SetGameState(_GameStateNew, false);
	}
}

void CGame::RenderLogo()
{
	if (_GameSubState == k_LOOP)
	{
		//render screen
		_g->SetColor(0x000000);
		_g->FillRect(0, 0, k_SCREEN_WIDTH, k_SCREEN_HEIGHT);
		if(_loading_step < 44)
		{
		
			_g->SetOpacity(_flag_opacity);
		
			
			_g->SetOpacity(100);
			
			if(_flag_opacity >= 100)
			{
				
				
			}
		}
		else
		{
			_g->SetColor(0xffffff);
			_g->FillRect(0, 0, k_SCREEN_WIDTH, k_SCREEN_HEIGHT);
						
			_g->SetOpacity(_menu_opacity);
			
			_g->SetOpacity(100);
		}
	}
}
